class Post < ActiveRecord::Base
  has_many :reservations
  belongs_to :category
  
  has_many :upcoming_reservations, :class_name => "Reservation", :foreign_key => "post_id", :conditions => ['reservations.start_date > ? AND reservations.state = ?', Time.now - 14.hours, 'paid'], :limit => 3, :include => [:post, :member]
  has_many :future_reservations, :class_name => "Reservation", :foreign_key => "post_id", :conditions => ['reservations.start_date > ? AND reservations.state = ?', Time.now - 14.hours, 'paid'], :order => 'start_date ASC', :limit => 20, :include => [:post, :member]
  
  file_column :image, :magick => { :versions => {
        :thumb => {:crop => "1:1", :size => "100x100!", :name => "thumb"},
        :normal => {:crop => "1:1", :size => "260x260>"} }, :quality => 75}
  
  validates_presence_of :title
end
